package gtkwire.widget;

import gtkwire.*;
import gtkwire.widget.utils.*;
import java.io.File;

/**
*A widget for displaying an image.
*/
public class GtkImage extends GtkMisc
{
        public GtkImage()
        {
		super();
		this.widgetType = WT_GtkImage;
		gtkCreate();
        }

        public GtkImage( String name, GladeKey key )
        {
		super( name, key );
		this.widgetType = WT_GtkImage;
        }

	/**
	*Sets GtkImage to display the file filename. If the file isn't found or can't be loaded, the resulting GtkImage will display a "broken image"
	* icon. If the file contains an animation, the image will contain an animation.
	*/
	public void setImageFromFile( File f )	
	{
		String path = f.getAbsolutePath();
		app().sendCommand( name, GTKWireCommandRequest.SET_IMAGE, path);
	}

	/**
	*Sets GtkImage to displaya stock icon. See GTK+ documentation for stock names.
	*@param stock_id  a stock icon name
	*@param size  a stock icon size expressed as GtkIconSize object.
	*/
	public void setImageFromStock( String stock_id, GtkIconSize size )	
	{
		String[] msg = new String[ 2 ];
		msg[ 0 ] = stock_id;
		msg[ 1 ] = size.getSize();
		app().sendCommand( name, GTKWireCommandRequest.SET_FROM_STOCK, msg);
	}

}//end class